package me.fung.wubi.resource

import java.io.File

/**
 * 读取 resources 路径下的资源
 */
object Resources {

    fun fileOrNull(path: String): File? {
        val resourcePath = if (path.startsWith("/")) path else "/$path"
        val url = this::class.java.getResource(resourcePath) ?: return null
        return File(url.toURI())
    }

    fun file(path: String): File {
        return fileOrNull(path) ?: throw IllegalStateException("No file $path")
    }

}